home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.02 Feb 95 / Yenta / Periodic Tasksƒ / CPPYReadTask.cp < prev    next >
Encoding:
Text File  |  1996-04-04  |  2.0 KB  |  77 lines  |  [TEXT/KAHL]

  1. /********************************************************* DEFINITION
  2.     DATE:    9/17/93
  3.     AUTHOR: Eric R. Rosé
  4.  
  5.     CLASS:  CPPYReadTask
  6.     
  7.     SUPERCLASS: CPPReadTask
  8.     
  9.         This C++ class subclasses CReadTask to define specific 
  10.         completion behavior for the Yenta Application
  11.     
  12. ********************************************************************/
  13.  
  14. #include "CPPTaskManager.h"
  15. #include "CPPYListenTask.h"
  16. #include "CPPYReadTask.h"
  17. #include "CPPList.h"
  18. #include <MemoryTools.h>
  19.  
  20. extern  CPPList            *gTalkText;
  21. extern    PPCPortRefNum    gOurPort;
  22.  
  23. /*-----------------------------------------------------------------*/
  24. /*------------------------ PUBLIC METHODS -------------------------*/
  25. /*-----------------------------------------------------------------*/
  26.  
  27.     CPPYReadTask::CPPYReadTask (CPPTaskManager *TaskManager, 
  28.                                 long minPeriod, 
  29.                                 Boolean deleteWhenDone) :
  30.                                   CPPReadTask (TaskManager, minPeriod,
  31.                                                deleteWhenDone)
  32.     {
  33.     
  34.     }
  35.     
  36. /*-----------------------------------------------------------------*/
  37.  
  38.     CPPYReadTask::~CPPYReadTask (void)
  39.     {
  40.     
  41.     }
  42.  
  43. /*-----------------------------------------------------------------*/
  44.  
  45.     char    *CPPYReadTask::ClassName (void)
  46.     {
  47.         return "CPPYReadTask";
  48.     }
  49.  
  50. /*-----------------------------------------------------------------*/
  51.  
  52.     void    CPPYReadTask::DoCompletedAction (void)
  53.     // when the task has completed, close the connection from our end
  54.     // and queue up another connection task
  55.     {
  56.         PPCEndPBRec            EndRec;
  57.         Boolean                AmITheOwner;
  58.         CPPYListenTask        *LTask = NULL;
  59.         
  60.         Handle    TempHandle = this->GetData (FALSE, &AmITheOwner);
  61.         
  62.         CPPReadTask::DoCompletedAction();
  63.         
  64.         // store a pointer to the text in a list where the Send dialog
  65.         //  can get it
  66.         gTalkText->AppendItem(Hand2Ptr(TempHandle));
  67.         
  68.         // Close the connection from our end
  69.         EndRec.sessRefNum = this->sessionID;
  70.         this->callResult = PPCEnd (&EndRec, FALSE);
  71.         
  72.         // make a new task to listen for other people trying to connect
  73.             LTask = new CPPYListenTask (this->ourManager, 60, TRUE);
  74.             LTask->StartListenTask(gOurPort, NULL);
  75.     }
  76.  
  77.